package com.ruoyi.work.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.work.mapper.WorkClientMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.work.mapper.WorkMediaPlaneMapper;
import com.ruoyi.work.domain.WorkMediaPlane;
import com.ruoyi.work.service.IWorkMediaPlaneService;
import com.ruoyi.common.core.text.Convert;

/**
 * 平面媒体资料Service业务层处理
 * 
 * @author ruoyi
 * @date 2022-01-02
 */
@Service
public class WorkMediaPlaneServiceImpl implements IWorkMediaPlaneService 
{
    @Autowired
    private WorkMediaPlaneMapper workMediaPlaneMapper;
    @Autowired
    private WorkClientMapper workClientMapper;
    /**
     * 查询平面媒体资料
     * 
     * @param mediaId 平面媒体资料主键
     * @return 平面媒体资料
     */
    @Override
    public WorkMediaPlane selectWorkMediaPlaneByMediaId(Long mediaId)
    {
        return workMediaPlaneMapper.selectWorkMediaPlaneByMediaId(mediaId);
    }

    /**
     * 查询平面媒体资料列表
     * 
     * @param workMediaPlane 平面媒体资料
     * @return 平面媒体资料
     */
    @Override
    public List<WorkMediaPlane> selectWorkMediaPlaneList(WorkMediaPlane workMediaPlane)
    {
        return workMediaPlaneMapper.selectWorkMediaPlaneList(workMediaPlane);
    }

    /**
     * 新增平面媒体资料
     * 
     * @param workMediaPlane 平面媒体资料
     * @return 结果
     */
    @Override
    public int insertWorkMediaPlane(WorkMediaPlane workMediaPlane)
    {
        workMediaPlane.setCreateTime(DateUtils.getNowDate());
        workMediaPlane.setContacts(workClientMapper.selectWorkClientByClientId(workMediaPlane.getContactId()).getClientName());

        return workMediaPlaneMapper.insertWorkMediaPlane(workMediaPlane);
    }

    /**
     * 修改平面媒体资料
     * 
     * @param workMediaPlane 平面媒体资料
     * @return 结果
     */
    @Override
    public int updateWorkMediaPlane(WorkMediaPlane workMediaPlane)
    {
        workMediaPlane.setUpdateTime(DateUtils.getNowDate());
        return workMediaPlaneMapper.updateWorkMediaPlane(workMediaPlane);
    }

    /**
     * 批量删除平面媒体资料
     * 
     * @param mediaIds 需要删除的平面媒体资料主键
     * @return 结果
     */
    @Override
    public int deleteWorkMediaPlaneByMediaIds(String mediaIds)
    {
        return workMediaPlaneMapper.deleteWorkMediaPlaneByMediaIds(Convert.toStrArray(mediaIds));
    }

    /**
     * 删除平面媒体资料信息
     * 
     * @param mediaId 平面媒体资料主键
     * @return 结果
     */
    @Override
    public int deleteWorkMediaPlaneByMediaId(Long mediaId)
    {
        return workMediaPlaneMapper.deleteWorkMediaPlaneByMediaId(mediaId);
    }
}
